package com.principle.ocp;

public class OcpE2 {
    public static void main(String[] args) {
        DrawEditor drawEditor = new DrawEditor();
        drawEditor.drawIt(new Circle1());
        drawEditor.drawIt(new Triangle1());
        drawEditor.drawIt(new Square1());
    }
}

class DrawEditor{
    public void drawIt(BaseShape shape){
        shape.draw();
    }
}
/**
 * 基类BaseShape，其中有抽象方法draw()
 */
abstract class BaseShape{
    abstract void draw();
}
/**
 * 下面是图形类
 */
class Circle1 extends BaseShape{
    @Override
    void draw() {
        System.out.println("Circle is draw");
    }
}
class Square1 extends BaseShape{
    @Override
    void draw() {
        System.out.println("Square is draw");
    }
}
class Triangle1 extends BaseShape{
    @Override
    void draw() {
        System.out.println("Triangle is draw");
    }
}